<template>
  <div>
    <div class="left">
      <i></i>
      <span class="tips">版本信息</span>
    </div>
    <el-table
      v-loading="loading"
      :data="tableData"
      highlight-current-row
      header-cell-class-name="table-header-class"
      style="width: 100%"
      height="380"
    >
      <el-table-column label="序号" type="index" align="center" width="70">
      </el-table-column>
      <el-table-column
        min-width="120"
        property="version"
        label="版本号"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>

      <el-table-column
        min-width="120"
        property="versionName"
        label="版本名称"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>

      <el-table-column
        min-width="120"
        property="createId"
        label="创建人"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>

      <el-table-column
        min-width="120"
        property="createTime"
        label="创建时间"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>

      <el-table-column
        label="操作"
        align="center"
        min-width="80"
      >
        <template slot-scope="scope">
          <span class="operationIcon" @click="view(scope.row)">
            <i class="el-icon-view"></i>
          </span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {
  getPhysicalRiskRuleVersionApi,
  getHealthRiskRuleVersionApi,
  getSpecialScoreRuleVersionApi,
  getUnderwritingEvaluationRuleVersionApi
} from "@/api/medicalLibrary/examProjectLibrary";

import constant from '@/utils/constant';
export default {
  props: {
    ruleType: {
      type: String,
      default: ''
    },
    diseaseRuleId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      tableData: [],
    };
  },
  methods:{
    // 获取所有版本信息
    getDataList(){
      this.loading = true
      this.tableData = []
      let api = this.ruleType == '1' ? getPhysicalRiskRuleVersionApi : this.ruleType == '2' ? getHealthRiskRuleVersionApi : 
                this.ruleType == '3' ? getSpecialScoreRuleVersionApi : getUnderwritingEvaluationRuleVersionApi
      api({diseaseRuleId: this.diseaseRuleId}).then(res => {
        this.loading = false
				this.$store.dispatch('loading/CHANGE_LOADING',false)
				if (res.resultCode == constant.SUCCESS) {
					this.tableData = res.data
				}
			}).catch(err => {
        this.loading = false
				this.$store.dispatch('loading/CHANGE_LOADING',false);
			});
    },
    // 点击列表查看按钮
    view(row){
      this.$emit('specifiedVersion',row.diseaseRuleId,row.version)
    }
  }
};
</script>

<style lang="less" scoped>
.left {
  margin-bottom: 12px;
  .tips {
    margin-left: 10px;
    font-weight: bold;
    float: left;
  }
  i {
    width: 2px;
    height: 16px;
    float: left;
    background: red;
    margin-top: 2px;
  }
}
/deep/ .el-loading-mask{
  background: transparent !important;
}
</style>